<template>
  <div class="dynamic_layer_wrap" ref="dynamicLayer">
    <template v-if="formVisible">
      <a-modal
        :getContainer="() => $refs.dynamicLayer"
        v-model:visible="formVisible"
        :width="formConfig.width ? formConfig.width : '70%'"
        :title="formConfig.title || '提示'"
        :centered="true"
        :footer="null"
        :zIndex="formConfig.zIndex || 1000"
        @cancel="layerCancel"
        :maskClosable="formConfig.maskClose ?? true"
      >
        <LayerDynamicForm :questions="questions.value" :config="formConfig"></LayerDynamicForm>
      </a-modal>
    </template>
    <template v-if="tableVisible">
      <a-modal
        :getContainer="() => $refs.dynamicLayer"
        v-model:visible="tableVisible"
        width="70%"
        :centered="true"
        :title="tableConfig.title || '提示'"
        :footer="null"
        :zIndex="tableConfig.zIndex || 1000"
        @cancel="layerCancel"
      >
        <LayerDynamicForm v-if="questions.value && questions.value.length" :questions="questions.value" :config="formConfig"></LayerDynamicForm>
        <DynamicTable :tables="tables.value" :config="tableConfig" :icons="icons.value"></DynamicTable>
      </a-modal>
    </template>
    <template v-if="uploadVisible">
      <a-modal
        :getContainer="() => $refs.dynamicLayer"
        v-model:visible="uploadVisible"
        :centered="true"
        :title="fileConfig.title || '上传文件'"
        width="424px"
        :zIndex="fileConfig.zIndex || 1000"
        :cancelText="uploadCommitButtonHidden ? '返回' : '取消'"
        @ok="handleUpload"
        @cancel="layerCancel"
        :ok-button-props="{
          disabled: uploadCommitButtonDisabled,
          loading: uploadCommitButtonLoading,
          style: { display: uploadCommitButtonHidden ? 'none' : '' }
        }"
      >
        <div ref="uploadViewRef" @click="getUploadViewDom">
          <a-upload-dragger
            name="file"
            :fileList="fileList"
            :multiple="fileConfig.multiple ?? false"
            :maxCount="fileConfig.multiple ? fileConfig.maxCount ?? 10 : 1"
            :headers="headers"
            :accept="fileConfig.accept || '*/*'"
            :progress="progress"
            :before-upload="beforeUpload"
            :customRequest="customRequest"
            @change="handleChange"
            @remove="handleRemove"
          >
            <p class="ant-upload-drag-icon">
              <inbox-outlined></inbox-outlined>
            </p>
            <p class="ant-upload-text">点击或将文件拖拽到这里上传</p>
            <div class="file_dow">
              <p class="ant-upload-hint" v-if="fileConfig.downloadUrl || fileConfig.downloadHeader">
                1、请点击<span @click.stop="download">{{ fileConfig.downloadName || '下载模板' }}</span>
              </p>
              <p class="ant-upload-hint" v-if="fileConfig.downloadRule">
                {{ `${fileConfig.downloadUrl || fileConfig.downloadHeader ? '2、' : ''}${fileConfig.downloadRule}` }}
              </p>
            </div>

            <template v-if="uploadCommitButtonHidden" #removeIcon="{ file }">
              <check-circle-two-tone v-if="file?.status === 'done'" two-tone-color="#52c41a" />
              <DeleteOutlined v-else />
            </template>
          </a-upload-dragger>
        </div>
        <template v-if="fileConfig.extendQuestion">
          <LayerDynamicForm ref="uploadLayerDynamicForm" :questions="fileConfig.extendQuestion" :config="fileConfig.extendConfig || { cancelSave: true }"></LayerDynamicForm>
        </template>
      </a-modal>
    </template>
  </div>
</template>

<script setup lang="ts">
import { DynamicTable, jsonToSheetXlsx, readerData } from '@/components/public-template';
import { uploadUrl } from '@/config/api/common/api';
import { $Http } from '@/config/service/http';
import { DYNAMICLAYERCLEAR, DYNAMICLAYERFORM, DYNAMICLAYERTABLE, DYNAMICLAYERUPLOAD, DYNAMICLOCALTABLE, UPLOADESERVE, UPLOADESERVEERROR } from '@/mixins/subject/subject-types';
import { useUserStoreWithOut } from '@/store/modules/user';
import { InboxOutlined } from '@ant-design/icons-vue';
import { UploadChangeParam, UploadProps, message } from 'ant-design-vue';
import { Subscription } from 'rxjs';
import { filter } from 'rxjs/operators';
import { getCurrentInstance, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue';
import XEUtils from 'xe-utils';
import LayerDynamicForm from '../DynamicForm/dynamic-form/dynamic-form.component.vue';
import { downloadFile } from '../publicMethod';
import { cancelUploadFileWithSliceRequest, uploadFileWithSlice } from './fileSliceUpload';

const { proxy }: any = getCurrentInstance();

let $subscribeSub: Subscription,
  name: any = null, //标识名字
  //表单
  formConfig: any = ref({}),
  formVisible: any = ref<boolean>(false),
  questions: any = reactive([]),
  //表格
  tableConfig: any = ref({}),
  tableVisible: any = ref<boolean>(false),
  tables: any = reactive([]),
  icons: any = [],
  //上传文件
  fileConfig: any = ref({}),
  uploadVisible: any = ref<boolean>(false),
  fileList: any = ref([]),
  fileUrl: any = ref(''),
  uploadLayerDynamicForm: any = ref();

const userStore = useUserStoreWithOut();
const accessToken: any = userStore.getToken;
const headers = {
  token: `${accessToken}`
};
const uploadCommitButtonDisabled = ref<boolean>(true);
const uploadCommitButtonLoading = ref<boolean>(false);
const uploadCommitButtonHidden = ref<boolean>(false);
let lastUploadFile: any = null;
const fileListOverflowStyle = ref('visible');
const fileListViewRef = ref();

onMounted(() => {
  subWatch();
});

watch(fileList, (newVal) => {
  if (newVal.length === 0) return;
  fileListOverflowStyle.value = newVal.length > 6 ? 'auto' : 'visible';
  nextTick(() => {
    fileListViewRef.value.scrollTop = fileListViewRef.value.scrollHeight;

    const listView = proxy.$refs.uploadViewRef;
    if (uploadCommitButtonHidden.value) {
      fileList.value.forEach((file, index) => {
        if (file.status === 'done') {
          const buttonDom = listView.getElementsByClassName('ant-btn ant-btn-text ant-btn-sm ant-upload-list-item-card-actions-btn ant-btn-icon-only')[index];
          buttonDom.style.opacity = 1;
        }
      });
      if (listView.fileListCount !== newVal.length) return;
      listView.fileListCount = newVal.length;
      const itemDomList = Array.from(listView.getElementsByClassName('ant-upload-list-text-container'));
      itemDomList.forEach((itemDom: any, index) => {
        const buttonDom = itemDom.getElementsByClassName('ant-btn ant-btn-text ant-btn-sm ant-upload-list-item-card-actions-btn ant-btn-icon-only')[0];
        itemDom.addEventListener(
          'mouseover',
          () => {
            buttonDom.title = fileList.value[index].status === 'done' ? '上传成功' : '删除文件';
            buttonDom.style.cursor = fileList.value[index].status === 'done' ? 'default' : 'pointer';
            buttonDom.style.opacity = 1;
          },
          true
        );
        itemDom.addEventListener(
          'mouseout',
          () => {
            buttonDom.style.opacity = fileList.value[index].status === 'uploading' ? 0 : 1;
          },
          true
        );
      });
    }
  });
});

const getUploadViewDom = async () => {
  await nextTick();
  const listView = proxy.$refs.uploadViewRef;
  fileListViewRef.value = listView.getElementsByClassName('ant-upload-list ant-upload-list-text')[0];
};

//取消弹层
const layerCancel = () => {
  formConfig.value = {};
  formVisible.value = false;
  questions.value = [];
  //表格
  tableConfig.value = {};
  tableVisible.value = false;
  tables.value = [];
  icons = [];
  //上传文件
  cancelUploadFileWithSliceRequest();
  fileConfig.value = {};
  uploadVisible.value = false;
  uploadCommitButtonDisabled.value = true;
  uploadCommitButtonLoading.value = false;
  fileListOverflowStyle.value = 'visible';
  fileList.value = [];
};
//初始化表单的值
const setFormValue = (data: any, questions: any) => {
  if (Array.isArray(questions) && questions.length) {
    questions.forEach((item: any) => {
      if (data[item.key]) {
        item.value = data[item.key];
      }
    });
  }
};

//监听动态表单数据完成
const subWatch = () => {
  $subscribeSub = proxy.$NotificationPubSub
    .getParams()
    .pipe(filter((res: any) => res !== 0))
    .subscribe((item: any) => {
      try {
        if (item.key === DYNAMICLAYERFORM) {
          //本地处理请求
          questions.value = item.value.form || item.value.part.state.form;
          formConfig.value = item.value.config || item.value.part.state.config;
          if (item.value.data) {
            if (formConfig.value.beforeWithMethod) {
              item.value.data = formConfig.value.beforeWithMethod(item.value.data);
            }
            setFormValue(item.value.data, questions.value);
          }
          formVisible.value = true;
        } else if (item.key === DYNAMICLAYERTABLE) {
          //本地处理请求
          tables.value = item.value.tables;
          tableConfig.value = item.value.config;
          tableConfig.value.index = item.value.index || 0;
          tableConfig.value.name = name = item.value.name || null;
          tableConfig.value.defaultValue = item.value.defaultValue || null;
          tableVisible.value = true;
          if (item.value.form) {
            questions.value = XEUtils.clone(item.value.form, true);
            formConfig.value = item.value.config;
            formConfig.value.searchForm = true; //弹层不自动请求
            formConfig.value.name = item.value.name;
          }
        } else if (item.key === DYNAMICLAYERUPLOAD) {
          uploadVisible.value = true;
          fileConfig.value = item.value.state;
          uploadCommitButtonHidden.value = fileConfig.value.hideOkButton ?? false;
          fileConfig.value.autoUploadFileServer = item.value.state.autoUploadFileServer ?? (fileConfig.value.downloadUrl || fileConfig.value.downloadHeader ? false : true);
          fileUrl.value = $Http.getUrl(item.value.state.uploadUrl ? item.value.state.uploadUrl : uploadUrl);
          console.log('看下地址', fileUrl.value);
          getUploadViewDom();
        }
        //本地弹层取消
        else if (item.key === DYNAMICLAYERCLEAR) {
          layerCancel();
        }
      } catch (error) {
        /* empty */
      }
    });
};

//进度条
const progress: UploadProps['progress'] = {
  strokeColor: {
    '0%': '#005AEA',
    '100%': '#52C41A'
  },
  strokeWidth: 3,
  format: (percent) => `${parseFloat(percent.toFixed(2))}%`
};

//上传文件
const handleChange = (info: UploadChangeParam) => {
  if (info.file.status === 'removed') cancelUploadFileWithSliceRequest(info.file.name);
  if (fileConfig.value.autoUploadFileServer) {
    if (fileConfig.value.multiple !== true || fileConfig.value.maxCount === 1) {
      // 上传单文件，替换
      if (info.file.status) {
        fileList.value = info.fileList.filter((item) => item.status);
        lastUploadFile = info.file;
      } else {
        fileList.value = lastUploadFile ? [lastUploadFile] : [];
      }
    } else {
      fileList.value = info.fileList.filter((item) => item.status);
    }
    uploadCommitButtonDisabled.value = fileList.value.length === 0 || !fileList.value.every((item) => item.status === 'done');
  } else {
    fileList.value = info.fileList.filter((file) => {
      const maxSize = fileConfig.value.size || 50;
      const isLt2M = file.size / 1024 / 1024 < maxSize;
      return isLt2M || fileConfig.value.cancelLimit;
    });
    uploadCommitButtonDisabled.value = fileList.value.length === 0;
  }
};

const handleRemove = (file) => {
  if (uploadCommitButtonHidden.value && file.status === 'done') return false;
  return true;
};

//上传前拦截
const beforeUpload = (file, selectedFileList) => {
  //本地表格解析
  if (fileConfig.value.type === 'localXlsx') {
    readerData(file)
      .then((data) => {
        if (data) {
          //丢给本地处理
          if (fileConfig.value.isLocal) {
            proxy.$NotificationPubSub.pushParams({
              key: DYNAMICLOCALTABLE,
              value: { data: data[0].results, part: fileConfig.value }
            });
            layerCancel();
            return;
          }
          if (fileConfig.value.url) {
            proxy.$Http.api(fileConfig.value.url, data[0].results, fileConfig.value.postType ? fileConfig.value.postType : 'post').then((data: any) => {
              message.success('上传成功！');
              layerCancel();
            });
          }
        }
      })
      .catch((err) => {});
    return false;
  }

  if (fileConfig.value.multiple && selectedFileList.length + fileList.value.length > (fileConfig.value.maxCount || (fileConfig.value.multiple ? 10 : 1)) && fileList.value.length !== 1) {
    debounce(async () => {
      message.error(`单次最多提交${fileConfig.value.maxCount || (fileConfig.value.multiple ? 10 : 1)}个文件`);
    }, 300);
    return false;
  }

  if (file.name.length > 120) {
    message.error(`文件名长度不能超过120`);
    return false;
  }

  // 过滤重名文件
  if (fileList.value.findIndex((item) => item.name === file.name) !== -1) {
    message.warning(`已忽略同名文件：${file.name}`);
    return false;
  }

  const maxSize = fileConfig.value.size || 50;
  const isLt2M = file.size / 1024 / 1024 < maxSize;
  if (!isLt2M && !fileConfig.value.cancelLimit) {
    let strMaxSize = maxSize >= 1024 ? `${Number((maxSize / 1024).toFixed(2))}G` : `${maxSize}M`;
    debounce(async () => {
      message.error(fileConfig.value.sizeTips ?? `上传文件大小不能大于${strMaxSize}`);
    }, 300);
    return false;
  }

  if (!fileConfig.value.autoUploadFileServer) {
    return false;
  }
};

const debounce = (function () {
  let timer = null;
  return function (callback, ms = 200) {
    clearTimeout(timer);
    timer = setTimeout(callback, ms);
  };
})();

// 自定义自动上传
const customRequest = ({ file, onProgress, onError, onSuccess }) => {
  if (uploadCommitButtonHidden.value || file.size > 6 * 1024 * 1024) {
    // 分片上传
    const params = { ...(fileConfig.value.autoParams ?? fileConfig.value.params ?? {}) };
    uploadFileWithSlice({
      category: fileConfig.value.category,
      file: file,
      params: params,
      filename: params.fileKey ?? 'file',
      onUploadProgress: (progress: { loaded: number; total: number }) => {
        let percents = Math.round((progress.loaded * 100) / progress.total);
        // 更新进度条
        onProgress({ percent: percents }, file);
      }
    })
      .then((result: any) => {
        if (result.success) {
          onSuccess(result, file);
          if (uploadCommitButtonHidden.value) {
            fileConfig.value.callback && fileConfig.value.callback(result);
            autoUploadNotication(result);
          }
        } else {
          onError(result.message, result, file);
        }
      })
      .catch((err) => {
        onError('上传失败', err, file);
      });
  } else {
    // 直接上传
    const params = new FormData();
    params.append('file', file);
    const temp = { ...(fileConfig.value.autoParams ?? {}) };
    for (const key in temp) {
      params.append(key, temp[key]);
    }
    const onUploadProgress = (progress: { loaded: number; total: number }) => {
      let percents = Math.round((progress.loaded * 100) / progress.total);
      // 更新进度条
      onProgress({ percent: percents }, file);
    };
    proxy.$Http
      .api(fileUrl.value, params, fileConfig.value.postType ? fileConfig.value.postType : 'post', '', '', { onUploadProgress: onUploadProgress }, 60000)
      .then((result: any) => {
        if (result.success) {
          onSuccess(result, file);
          if (uploadCommitButtonHidden.value) {
            fileConfig.value.callback && fileConfig.value.callback(result);
            autoUploadNotication(result);
          }
        } else {
          onError(result.message, result, file);
        }
      })
      .catch((err) => {
        onError('上传失败', err, file);
      });
  }
};

const autoUploadNotication = (result) => {
  proxy.$NotificationFormSub.pushParams({
    key: UPLOADESERVE,
    name: fileConfig.value.name || '',
    value: result
  });
};

// 确认上传
const handleUpload = async () => {
  if (fileConfig.value.splitRequest) {
    // 拆分成单个单个附件上传
    const promiseArr = [];
    for (let i = 0; i < fileList.value.length; i++) {
      if (fileConfig.value.beforeWithMethod) {
        // 提交拦截
        let temp = fileConfig.value.beforeWithMethod(fileConfig.value.autoUploadFileServer ? fileList.value[i].response?.data?.id : fileList.value[i]);
        if (!temp) {
          continue;
        }
        if (!fileConfig.value.url || fileConfig.value.url.length === 0) {
          console.warn('没有配置请求地址url');
          continue;
        }
        let params: any;
        if (fileConfig.value.autoUploadFileServer) {
          params = temp;
        } else {
          params = new FormData();
          params.append(fileConfig.value.keyName || 'file', fileList.value[i].originFileObj);
          for (const key in temp) {
            params.append(key, temp[key]);
          }
        }
        promiseArr.push(proxy.$Http.api(fileConfig.value.url, params, fileConfig.value.postType ? fileConfig.value.postType : 'post', '', '', fileConfig.value.httpOpt, 60000));
      } else {
        let temp = { ...(fileConfig.value.params ?? {}) };
        if (!fileConfig.value.url || fileConfig.value.url.length === 0) {
          console.warn('没有配置请求地址url');
          continue;
        }

        let params: any;
        if (fileConfig.value.autoUploadFileServer) {
          temp[fileConfig.value.keyName || 'file'] = fileList.value[i].response?.data?.id ?? '';
          params = temp;
        } else {
          params = new FormData();
          params.append(fileConfig.value.keyName || 'file', fileList.value[i].originFileObj);
          for (const key in temp) {
            params.append(key, temp[key]);
          }
        }
        promiseArr.push(proxy.$Http.api(fileConfig.value.url, params, fileConfig.value.postType ? fileConfig.value.postType : 'post', '', '', fileConfig.value.httpOpt, 60000));
      }
    }
    if (promiseArr.length === 0) {
      return;
    }
    uploadCommitButtonLoading.value = true;
    const resultList = await Promise.all(promiseArr);
    uploadCommitButtonLoading.value = false;
    if (resultList.every((item) => item.success)) {
      !fileConfig.value.hideMessage && message.success('上传成功！');
      const resList = resultList.map((item) => item.data);
      fileConfig.value.callback && fileConfig.value.callback(resList);
      layerCancel();
      proxy.$NotificationFormSub.pushParams({
        key: UPLOADESERVE,
        name: fileConfig.value.name || '',
        value: resList
      });
    } else {
      proxy.$NotificationFormSub.pushParams({
        key: UPLOADESERVEERROR,
        name: fileConfig.value.name || '',
        value: resultList
      });
    }
  } else {
    let params;
    if (fileConfig.value.beforeWithMethod) {
      if (fileConfig.value.autoUploadFileServer) {
        // 传给外部 单文件为文件id，多文件为文件id数组
        if (fileConfig.value.beforeWithMethodRequireData) {
          params = fileConfig.value.beforeWithMethod(fileConfig.value.multiple ? fileList.value.map((item) => item.response?.data) : fileList.value[0].response?.data);
        } else {
          params = fileConfig.value.beforeWithMethod(fileConfig.value.multiple ? fileList.value.map((item) => item.response?.data?.id) : fileList.value[0].response?.data?.id);
        }
      } else {
        // 传给外部 单文件为文件对象，多文件为文件对象数组
        params = fileConfig.value.beforeWithMethod(fileConfig.value.multiple ? fileList.value.map((item) => item) : fileList.value[0]);
      }
    } else {
      let temp1;
      if (fileConfig.value.multiple) {
        temp1 = fileList.value.map((file) => {
          let temp = { ...(fileConfig.value.params ?? {}) };
          temp[fileConfig.value.keyName || 'file'] = file.response?.data?.id ?? '';
          return temp;
        });
      } else {
        let temp = { ...(fileConfig.value.params ?? {}) };
        temp[fileConfig.value.keyName || 'file'] = fileList.value[0].response?.data?.id ?? '';
        temp1 = temp;
      }

      if (!fileConfig.value.autoUploadFileServer && (fileConfig.value.downloadUrl || fileConfig.value.downloadHeader)) {
        params = new FormData();
        fileList.value.forEach((file) => {
          params.append(fileConfig.value.keyName || 'file', file.originFileObj);
        });
        let temp2 = { ...(fileConfig.value.params ?? {}) };
        for (const key in temp2) {
          params.append(key, temp2[key]);
        }
      } else {
        params = temp1;
      }
    }
    if (!params) return;

    if (fileConfig.value.autoUploadFileServer || fileConfig.value.beforeWithMethod || fileConfig.value.downloadUrl || fileConfig.value.downloadHeader) {
      if (!fileConfig.value.url || fileConfig.value.url.length === 0) {
        console.warn('没有配置请求地址url');
        return;
      }
      uploadCommitButtonLoading.value = true;
      proxy.$Http
        .api(fileConfig.value.url, params, fileConfig.value.postType ? fileConfig.value.postType : 'post', '', '', fileConfig.value.httpOpt, 60000)
        .then((result: any) => {
          if (result.success) {
            !fileConfig.value.hideMessage && message.success('上传成功！');
            fileConfig.value.callback && fileConfig.value.callback(result?.data);
            proxy.$NotificationFormSub.pushParams({
              key: UPLOADESERVE,
              name: fileConfig.value.name || '',
              value: result?.data
            });
            layerCancel();
          } else {
            proxy.$NotificationFormSub.pushParams({
              key: UPLOADESERVEERROR,
              name: fileConfig.value.name || '',
              value: result
            });
          }
        })
        .finally(() => {
          uploadCommitButtonLoading.value = false;
        });
    } else {
      uploadCommitButtonLoading.value = true;
      const requestArr = [];
      if (fileConfig.value.multiple) {
        params.forEach((item, index) => {
          requestArr.push(
            uploadFileWithSlice({
              category: fileConfig.value.category,
              file: fileList.value[index].originFileObj,
              params: item,
              filename: params.fileKey ?? 'file'
            })
          );
        });
      } else {
        requestArr.push(
          uploadFileWithSlice({
            category: fileConfig.value.category,
            file: fileList.value[0].originFileObj,
            params: params,
            filename: params.fileKey ?? 'file'
          })
        );
      }
      const resultList = await Promise.all(requestArr);
      uploadCommitButtonLoading.value = false;
      if (resultList.every((item) => item.success)) {
        !fileConfig.value.hideMessage && message.success('上传成功！');
        const resList = resultList.map((item) => item.data);
        fileConfig.value.callback && fileConfig.value.callback(fileConfig.value.multiple ? resList : resList[0]);
        layerCancel();
        proxy.$NotificationFormSub.pushParams({
          key: UPLOADESERVE,
          name: fileConfig.value.name || '',
          value: fileConfig.value.multiple ? resList : resList[0]
        });
      } else {
        proxy.$NotificationFormSub.pushParams({
          key: UPLOADESERVEERROR,
          name: fileConfig.value.name || '',
          value: resultList
        });
      }
    }
  }
};

//下载文件
const download = () => {
  if (fileConfig.value.downloadUrl) {
    let params = Object.assign({}, fileConfig.value.downloadParams || {});
    proxy.$Http.api(fileConfig.value.downloadUrl, params, fileConfig.value.downloadProtType ? fileConfig.value.downloadProtType : 'get', '', '', { responseType: 'blob' }, 60000).then((data: any) => {
      if (data) {
        downloadFile(data, fileConfig.value.downloadFileName ? fileConfig.value.downloadFileName + '.xlsx' : '模版文件.xlsx');
        return;
      } else {
        message.error('导出数据失败');
      }
    });
  } else if (fileConfig.value.downloadHeader) {
    jsonToSheetXlsx({
      data: fileConfig.value.data || [],
      header: fileConfig.value.downloadHeader,
      filename: fileConfig.value.downloadFileName ? fileConfig.value.downloadFileName + '.xlsx' : '模板文件.xlsx',
      json2sheetOpts:
        fileConfig.value?.json2sheetOpts ||
        {
          // 指定顺序
          // header: ['name', 'id'],
        }
    });
  }
};

onUnmounted(() => {
  if ($subscribeSub != undefined) {
    $subscribeSub.unsubscribe();
  }
  proxy.$NotificationPubSub.clearParams();
});
</script>

<style lang="less" scoped>
@import url('./dynamic-layer.component.less');

.dynamic_layer_wrap {
  :deep(.ant-upload-list.ant-upload-list-text) {
    max-height: 200px;
    overflow-y: v-bind(fileListOverflowStyle);
    scroll-behavior: smooth;

    &::-webkit-scrollbar {
      width: 0; /*  设置纵轴（y轴）轴滚动条 */
      height: 0; /*  设置横轴（x轴）轴滚动条 */
    }

    /* hover时显色 */
    &:hover::-webkit-scrollbar {
      width: 4px; /*  设置纵轴（y轴）轴滚动条 */
      height: 4px; /*  设置横轴（x轴）轴滚动条 */
    }

    /* 滚动条滑块（里面小方块） */
    &::-webkit-scrollbar-thumb {
      border-radius: 10px;
      box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      background: rgba(0, 0, 0, 0.2);
    }

    /* 滚动条轨道 */
    &::-webkit-scrollbar-track {
      border-radius: 0;
      box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      background: rgba(0, 0, 0, 0.1);
    }
  }

  :deep(.ant-upload-list-item-card-actions) {
    z-index: 1;
  }

  :deep(.ant-upload-list-item-progress) {
    width: 97%;
  }
}
</style>
